home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
os2
/
octa209s.zip
/
octave-2.09
/
libcruft
/
minpack
/
hybrj1.f
< prev
next >
Wrap
Text File
|
1996-07-19
|
4KB
|
128 lines
SUBROUTINE HYBRJ1(FCN,N,X,FVEC,FJAC,LDFJAC,TOL,INFO,WA,LWA)
INTEGER N,LDFJAC,INFO,LWA
DOUBLE PRECISION TOL
DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N),WA(LWA)
EXTERNAL FCN
C **********
C
C SUBROUTINE HYBRJ1
C
C THE PURPOSE OF HYBRJ1 IS TO FIND A ZERO OF A SYSTEM OF
C N NONLINEAR FUNCTIONS IN N VARIABLES BY A MODIFICATION
C OF THE POWELL HYBRID METHOD. THIS IS DONE BY USING THE
C MORE GENERAL NONLINEAR EQUATION SOLVER HYBRJ. THE USER
C MUST PROVIDE A SUBROUTINE WHICH CALCULATES THE FUNCTIONS
C AND THE JACOBIAN.
C
C THE SUBROUTINE STATEMENT IS
C
C SUBROUTINE HYBRJ1(FCN,N,X,FVEC,FJAC,LDFJAC,TOL,INFO,WA,LWA)
C
C WHERE
C
C FCN IS THE NAME OF THE USER-SUPPLIED SUBROUTINE WHICH
C CALCULATES THE FUNCTIONS AND THE JACOBIAN. FCN MUST
C BE DECLARED IN AN EXTERNAL STATEMENT IN THE USER
C CALLING PROGRAM, AND SHOULD BE WRITTEN AS FOLLOWS.
C
C SUBROUTINE FCN(N,X,FVEC,FJAC,LDFJAC,IFLAG)
C INTEGER N,LDFJAC,IFLAG
C DOUBLE PRECISION X(N),FVEC(N),FJAC(LDFJAC,N)
C ----------
C IF IFLAG = 1 CALCULATE THE FUNCTIONS AT X AND
C RETURN THIS VECTOR IN FVEC. DO NOT ALTER FJAC.
C IF IFLAG = 2 CALCULATE THE JACOBIAN AT X AND
C RETURN THIS MATRIX IN FJAC. DO NOT ALTER FVEC.
C ---------
C RETURN
C END
C
C THE VALUE OF IFLAG SHOULD NOT BE CHANGED BY FCN UNLESS
C THE USER WANTS TO TERMINATE EXECUTION OF HYBRJ1.
C IN THIS CASE SET IFLAG TO A NEGATIVE INTEGER.
C
C N IS A POSITIVE INTEGER INPUT VARIABLE SET TO THE NUMBER
C OF FUNCTIONS AND VARIABLES.
C
C X IS AN ARRAY OF LENGTH N. ON INPUT X MUST CONTAIN
C AN INITIAL ESTIMATE OF THE SOLUTION VECTOR. ON OUTPUT X
C CONTAINS THE FINAL ESTIMATE OF THE SOLUTION VECTOR.
C
C FVEC IS AN OUTPUT ARRAY OF LENGTH N WHICH CONTAINS
C THE FUNCTIONS EVALUATED AT THE OUTPUT X.
C
C FJAC IS AN OUTPUT N BY N ARRAY WHICH CONTAINS THE
C ORTHOGONAL MATRIX Q PRODUCED BY THE QR FACTORIZATION
C OF THE FINAL APPROXIMATE JACOBIAN.
C
C LDFJAC IS A POSITIVE INTEGER INPUT VARIABLE NOT LESS THAN N
C WHICH SPECIFIES THE LEADING DIMENSION OF THE ARRAY FJAC.
C
C TOL IS A NONNEGATIVE INPUT VARIABLE. TERMINATION OCCURS
C WHEN THE ALGORITHM ESTIMATES THAT THE RELATIVE ERROR
C BETWEEN X AND THE SOLUTION IS AT MOST TOL.
C
C INFO IS AN INTEGER OUTPUT VARIABLE. IF THE USER HAS
C TERMINATED EXECUTION, INFO IS SET TO THE (NEGATIVE)
C VALUE OF IFLAG. SEE DESCRIPTION OF FCN. OTHERWISE,
C INFO IS SET AS FOLLOWS.
C
C INFO = 0 IMPROPER INPUT PARAMETERS.
C
C INFO = 1 ALGORITHM ESTIMATES THAT THE RELATIVE ERROR
C BETWEEN X AND THE SOLUTION IS AT MOST TOL.
C
C INFO = 2 NUMBER OF CALLS TO FCN WITH IFLAG = 1 HAS
C REACHED 100*(N+1).
C
C INFO = 3 TOL IS TOO SMALL. NO FURTHER IMPROVEMENT IN
C THE APPROXIMATE SOLUTION X IS POSSIBLE.
C
C INFO = 4 ITERATION IS NOT MAKING GOOD PROGRESS.
C
C WA IS A WORK ARRAY OF LENGTH LWA.
C
C LWA IS A POSITIVE INTEGER INPUT VARIABLE NOT LESS THAN
C (N*(N+13))/2.
C
C SUBPROGRAMS CALLED
C
C USER-SUPPLIED ...... FCN
C
C MINPACK-SUPPLIED ... HYBRJ
C
C MINPACK. VERSION OF JULY 1979.
C BURTON S. GARBOW, KENNETH E. HILLSTROM, JORGE J. MORE
C
C **********
INTEGER J,LR,MAXFEV,MODE,NFEV,NJEV,NPRINT
DOUBLE PRECISION FACTOR,ONE,XTOL,ZERO
DATA FACTOR,ONE,ZERO /1.0D2,1.0D0,0.0D0/
INFO = 0
C
C CHECK THE INPUT PARAMETERS FOR ERRORS.
C
IF (N .LE. 0 .OR. LDFJAC .LT. N .OR. TOL .LT. ZERO
* .OR. LWA .LT. (N*(N + 13))/2) GO TO 20
C
C CALL HYBRJ.
C
MAXFEV = 100*(N + 1)
XTOL = TOL
MODE = 2
DO 10 J = 1, N
WA(J) = ONE
10 CONTINUE
NPRINT = 0
LR = (N*(N + 1))/2
CALL HYBRJ(FCN,N,X,FVEC,FJAC,LDFJAC,XTOL,MAXFEV,WA(1),MODE,
* FACTOR,NPRINT,INFO,NFEV,NJEV,WA(6*N+1),LR,WA(N+1),
* WA(2*N+1),WA(3*N+1),WA(4*N+1),WA(5*N+1))
IF (INFO .EQ. 5) INFO = 4
20 CONTINUE
RETURN
C
C LAST CARD OF SUBROUTINE HYBRJ1.
C
END